package Disizhou;

import java.util.Arrays;

public class Kuaisupaixu {
    public static void main(String[] args) {
        int[]arr={12,34,2,5,6,67,87};
        System.out.println("Arrays.toString() = " + Arrays.toString(arr));
        startsort(arr,0, arr.length-1);
        System.out.println("Arrays.toString() = " + Arrays.toString(arr));
    }
    public static void startsort(int []arr1,int l,int r){
        if (l<r){
            int base=arr1[l];
            int left=l;
            int right=r;
            while (left < right) {
                while (left<right && arr1[right]>=base){
                    right--;
                }
                arr1[left]=arr1[right];
                while (left<right && arr1[left]<=base){
                    left++;
                }
                arr1[right]=arr1[left];
            }
            arr1[left]=base;
            startsort(arr1,l,left-1);
            startsort(arr1,right+1,r);
        }
    }
}
